<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!doctype html>
<html lang="en">
<head>
    <%@include file="/WEB-INF/pages/common/head.jsp"%>
</head>
<body>
<div class="container">
    <c:set var="count" value="0"/>
    <c:set var="total" value="0"/>
    <c:forEach items="${child}" var="a">
        <c:set var="dictionary" value="${a.dictionary}"/>
        <c:set var="count" value="${count+a.totalPrice}"/>
        <c:set var="total" value="${total+a.purchaseBuy}"/>

    </c:forEach>
    <div class="row">
        <div class="col-md-3">采购单号:${master.purchaseNo}</div>
        <div class="col-md-3">供应商:${master.supply.supplyName}</div>
        <div class="col-md-3">采购单生成日期:<fmt:formatDate value="${master.createDate}" pattern="yyyy-MM-dd"/> </div>
        <div class="col-md-3">总金额（元）:${count}</div>
    </div>
    <table class="table" id="am">
        <tr>
            <th>序号</th>
            <th>物资编码</th>
            <th>助记码</th>
            <th>物资名称</th>
            <th>物资单位</th>
            <th>物资规格</th>
            <th>采购数量</th>
            <th>单价（元）</th>
            <th>合计（元）</th>
        </tr>
        <c:forEach items="${child}" var="a">
            <c:set var="dictionary" value="${a.dictionary}"/>
            <tr>
                <td>${a.purchaseChildId}</td>
                <td>${a.cgCode}</td>
                <td>${a.dictionary.inputCode}</td>
                <td>${a.dictionary.cgName}</td>
                <td>${a.dictionary.packUnit}</td>
                <td>${a.dictionary.packSpec}</td>
                <td>${a.purchaseBuy}</td>
                <td>${a.dictionary.price}</td>
                <td>${a.totalPrice}</td>
            </tr>
        </c:forEach>
    </table>
    <div class="row">
        <div class="col-md-4">
            审核：
            <select name="shenhe" class="form-control">
                <option value="3">审核通过</option>
                <option value="2">审核不通过</option>
            </select>
        </div>
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
    </div>
    <div class="row">
        <div class="col-md-4"></div>
        <div class="col-md-4"></div>
        <div class="col-md-4">
            <button onclick="baocun()" class="btn btn-default">保存</button>
            <button onclick="location.href='procurement/orderConfirm/index'" class="btn btn-default">返回</button>

        </div>
    </div>

</div>
<%@include file="/WEB-INF/pages/common/modal.jsp"%>
<script>
    $("th,td").addClass("text-center");
    $("th,td").css({"border":"1px solid #dddddd"});
    function baocun() {
        var param ="purchaseMasterId="+'${master.purchaseMasterId}'+"&orderStatus="+$("select[name='shenhe']").val();
        $.post("procurement/orderGenerate/update1",param,function (msg) {
            swal({title:msg,
                type:"success",confirmButtonText:"OK"}
            ).then(
                function(isConfirm) {
                    if(isConfirm){
                        location='procurement/orderConfirm/index'
                    }
                }
            )
        },'text')
    }
</script>
</body>
</html>